package com.chaoyi.service.Impl;

import com.chaoyi.config.WSUploadConfig;
import com.chaoyi.service.UploadClassifyVideoService;
import com.chaoyi.util.UUIDUtil;
import com.chaoyi.util.oss.ApkOSSConfigure;
import com.chaoyi.util.oss.ApkOSSManageUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.servlet.http.Part;
import java.io.IOException;

/**
 * @Auther: 卜加超
 * @Date: 2018/12/27 16:12
 * @Description:
 */
@Service
public class UploadClassifyVideoServiceImpl implements UploadClassifyVideoService {
    private Logger log = LoggerFactory.getLogger(UploadClassifyVideoServiceImpl.class);
    @Override
    public String uploadClassifyVideo2WSCDN(Part uploadFile) throws Exception {
        String exten = uploadFile.getSubmittedFileName().substring(uploadFile.getSubmittedFileName().lastIndexOf("."));
        String fileName = UUIDUtil.getUUID() + exten;
        return ApkOSSManageUtil.uploadFile(new ApkOSSConfigure(), uploadFile, WSUploadConfig.videoCollectionPath,
                fileName);
    }

    @Override
    public String uploadClassifyImg2WSCDN(Part uploadFile) throws Exception {
        String exten = uploadFile.getSubmittedFileName().substring(uploadFile.getSubmittedFileName().lastIndexOf("."));
        String fileName = UUIDUtil.getUUID() + exten;
        return ApkOSSManageUtil.uploadFile(new ApkOSSConfigure(), uploadFile, WSUploadConfig.videoCollectionImgUrlPath,
                fileName);
    }

}
